//
//  AppDelegate.m
//  LoveOfPet
//
//  Created by dllo on 15/11/11.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "AppDelegate.h"
#import "CircleOfPetViewController.h"
#import "PetAmuseViewController.h"
#import "RegisterOfPetViewController.h"
#import "MyViewController.h"
#import "EAIntroView.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];
    self.window.backgroundColor = [UIColor whiteColor];
    [self creatTabBar];
    [self.window makeKeyAndVisible];

    return YES;
}
-(void)creatTabBar
{
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    tabBar.tabBar.tintColor = [UIColor orangeColor];
    
    UINavigationController *circleOfPet = [[UINavigationController alloc] initWithRootViewController:[[CircleOfPetViewController alloc] init]];
    circleOfPet.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"宠物圈" image:[UIImage imageNamed:@"chongwuquan"] selectedImage:[UIImage imageNamed:@"chongwuquan2"]];
    
    UINavigationController *petAmuse = [[UINavigationController alloc] initWithRootViewController:[[PetAmuseViewController alloc] init]];
    
    petAmuse.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"萌宠搞笑" image:[UIImage imageNamed:@"gaoxiao"] selectedImage:[UIImage imageNamed:@"gaoxiao2"]];
    
    UINavigationController *registerOfPet = [[UINavigationController alloc] initWithRootViewController:[[RegisterOfPetViewController alloc] init]];
    
    registerOfPet.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"急诊挂号" image:[UIImage imageNamed:@"jijiu"] selectedImage:[UIImage imageNamed:@"jijiu2"]];
    
    UINavigationController *my = [[UINavigationController alloc] initWithRootViewController:[[MyViewController alloc] init]];
    
    my.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的萌宠" image:[UIImage imageNamed:@"wode"] selectedImage:[UIImage imageNamed:@"wode2"]];

    tabBar.viewControllers = @[petAmuse, circleOfPet, registerOfPet, my];
    
    self.window.rootViewController = tabBar;
}

//-(void)Jpush
//{
//    if ([[UIDevice currentDevice].systemName floatValue] >= 8.0f) {
//        [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
//    }else
//    {
//        // categories 必须为空
//        [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
//    }
//    
//    // 初始化
//    [APService setupWithOption:launchOptions];
//}

//引导页
- (void)showIntroWithCrossDissolve {
    
    EAIntroPage *page1 = [EAIntroPage page];
    page1.title = @"";
    page1.desc = @"";
    page1.bgImage = [UIImage imageNamed:@"page1.jpg"];
    
    EAIntroPage *page2 = [EAIntroPage page];
    page2.bgImage = [UIImage imageNamed:@"page2.jpg"];
    
    EAIntroPage *page3 = [EAIntroPage page];
    page3.desc = @"";
    page3.bgImage = [UIImage imageNamed:@"page3.jpg"];
    
    EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.window.bounds andPages:@[page1,page2,page3]];
//    [intro setDelegate:self];
    [intro showInView:self.window animateDuration:0];
    [intro release];
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    
    //判断是不是第一次加载
    NSString *firstLoad = @"FIRSTLOAD";
    if (![[NSUserDefaults standardUserDefaults] objectForKey:firstLoad]) {
        [self showIntroWithCrossDissolve];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:firstLoad];
    }
    
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
